//
//  MineApi.swift
//  Pods
//
//  Created by eme on 2017/3/23.
//
//

import Foundation
import Alamofire
import ModelProtocol
import NetWorkCore

extension String {
    func getMd5Password() -> String {
        
        return "\(self)eme909014123561236jkwsdfjdw".md5()
    }
}
public enum MineApi{
    case getAddressList()
    case changeAddress(addid:String)
    case getCollectGoodsList(page:Int,length:Int)
    case changeAddressOrAddNewAddress(message:String)
    case getCollectBrandList(page:Int,length:Int)
    case getFootPrintList(page:Int,length:Int)
    case getshopMessage(spid:String)
    case getCodeForMine(phone:String,type:String)
    case checkCode(phone:String,code:String,type:String)
    case deleteBrandCollect(cid:String,page:Int,length:Int)
    case deleteGoodsCollect(cid:String,page:Int,length:Int)
    case deleteShopAddress(addid:String)
    case changeStroeMessage(glshop:String)
    case buildNewPhone(phone:String,type:String,code:String)
    case getBrandMoreList(page:Int,length:Int)
    case getOrderList(page:Int,length:Int,orderType:String,isevaluate:String)
    case getOrderDetails(orderID:String,iscanevaluate:String)
    case getOrderGroup(orderid:String,pdid:String)
    case confirmOrder(orderid:String)
    case submitEvaluate(orderevaluate:String)
    case deleteOrder(orderid:String)
    case cancelOrder(payid:String)
    case getOrderLogistics(orderid:String)
    case getOrderNum()
    case getComplainType()
    case submitComplain(jsonStr:String)
    case deleteFootPrint(fid:String)
    case submitFeedBack(jsonStr:String)
    case getLoginUserModel()
    case changeOrderStatus_Cancel(orderid:String,iscanevaluate:String,payid:String)
    case changeOrderStatus_Confirm(orderid:String,iscanevaluate:String)
    case getMessageList(type:String,begin:Int,length:Int)
    case getCouponsList(vstate:String)
    case getComplaintsDetaile(id:String)
    case getFeedBackDetaile(id:String)
    case loginOut()
    case messageRed(mid:String)
    case getOrderKD(id:String)
    case getMessageCount()
    case getTKDetaile(detailid:String)
    case login(id:String,password:String)
    case glproductskus(pdid:String)
}
extension MineApi:TargetType{
    public var path:String{
        switch self {
        case .getAddressList:
            return "/glShopAddress/a/list.json"                             ///收货地址列表
        case .getCollectBrandList(_,_):
            return "/usBdCollection/a/bdlist.json"                          ///收藏品牌列表
        case .changeAddress(_):
            return "/glShopAddress/a/shopaddress.json"                      ///获取收货地址对象(编辑or修改时)
        case .changeAddressOrAddNewAddress(_):
            return "/glShopAddress/a/save.json"                             ///修改或添加新的地址
        case .getCollectGoodsList(_,_):
            return "/usPdCollection/a/pdlist.json"                          ///收藏商品列表
        case .getFootPrintList(_,_):
            return "/usPdFootprint/a/pdfootprintlist.json"                  ///获取足迹列表
        case .getshopMessage(_):
            return "/glShop/a/myshop.json"                                  ///获取店铺信息
        case .getCodeForMine(_,_):
            return "/cpUser/sendmsg.json"                                   ///发送手机验证码
        case .checkCode(_,_,_):
            return "/cpUser/checkcode.json"                                 ///验证手机验证码
        case .deleteBrandCollect(_,_,_):
            return "/usBdCollection/a/del.json"                             ///删除品牌收藏
        case .deleteGoodsCollect(_,_,_):
            return "/usPdCollection/a/del.json"                             ///删除商品收藏
        case .deleteShopAddress(_):
            return "/glShopAddress/a/del.json"                              ///删除收货地址
        case .changeStroeMessage(_):
            return "/glShop/a/update.json"                                  ///修改店铺信息
        case .buildNewPhone(_,_,_):
            return "/cpUser/a/changephone.json"                             ///绑定新手机
        case .getBrandMoreList(_,_):
            return "/firstPage/a/getbrandmore.json"                         ///获取更多品牌
        case .getOrderList(_,_,_,_):
            return "/osOrder/a/orderlist.json"                              ///获取订单列表
        case .getOrderDetails(_,_):
            return "/osOrder/a/orderdetail.json"                            ///订单详情
        case .getOrderGroup(_,_):
            return "/osOrder/ordergroup.json"                               ///查看组合商品
        case .confirmOrder(_):
            return "/osOrder/a/confirmreceipt.json"                         ///订单确认收货
        case .submitEvaluate(_):
            return "/osOrderEvaluate/a/evaluateorderdetails.json"           ///订单评价
        case .deleteOrder(_):
            return "/osOrder/a/delorder.json"                               ///删除订单
        case .cancelOrder(_):
            return "/osOrder/a/cancelorder.json"                            ///取消订单
        case .getOrderLogistics(_):
            return "/osOrderLogistics/a/list.json"                          ///快递列表
        case .getOrderNum():
            return "/osOrder/a/ordercounts.json"                            ///获取订单数量
        case .getComplainType():
            return "/osOrderComplain/a/showAdd.json"                        ///获取投诉类型
        case .submitComplain(_):
            return "/osOrderComplain/a/saveOsOrderComplain.json"            ///提交投诉
        case .deleteFootPrint(_):
            return "/usPdFootprint/a/del.json"                              ///删除足迹
        case .submitFeedBack(_):
            return "/osFeedback/a/add.json"                                 ///提交意见反馈
        case .getLoginUserModel():
            return "/a/relogin.json"                                        ///获取登录对象
        case .changeOrderStatus_Cancel(_,_,_):
            return "/osOrder/a/cancelordertime.json"                        ///取消订单_(待付款状态时)
        case .changeOrderStatus_Confirm(_,_):
            return "/osOrder/a/confirmreceipttime.json"                     ///确认收货_(待收货状态)
        case .getMessageList(_,_,_):
            return "/firstPage/a/getmessage.json"                           ///获取消息列表
        case .getCouponsList(_):
            return "/opVoucherUser/a/list.json"                             ///获取优惠券列表
        case .getComplaintsDetaile(_):
            return "/osOrderComplain/a/complaindetail.json"                 ///获取投诉详情
        case .getFeedBackDetaile(_):
            return "/osFeedback/a/feedbackdetail.json"                      ///获取意见反馈详情
        case .loginOut():
            return "/logout.json"                                           ///退出登录
        case .messageRed(_):
            return "/firstPage/a/readmessage.json"                          ///消息已读标记
        case .getOrderKD(_):
            return "/osOrder/a/orderkuaidi.json"                            ///获取物流信息
        case .getMessageCount():
            return "/osOrder/a/messagecount.json"                           ///获取消息数量
        case .getTKDetaile(_):
            return "/osOrder/a/orderbackpaydetail.json"
        case .login(id: _, password: _):
            return "/login.json"
        case .glproductskus:                                                ///获取SKU
            return "/glProduct/skus.json"
        }
    }
    public var method: HTTPMethod{
        switch self {
        default:
            return .post
        }
    }
    public var parameters:Parameters?{
        switch  self {
        case let .getCollectBrandList(page,length):
            return ["length":length,"page":page]
        case let .changeAddress(addid):
            return ["addid":addid]
        case let .changeAddressOrAddNewAddress(message):
            return ["glShopAddress":message]
        case let .getCollectGoodsList(page,length):
            return ["page":page,"length":length]
        case let .getshopMessage(spid):
            return ["spid":spid]
        case let .getCodeForMine(phone,type):
            return ["phone":phone,"type":type]
        case let .checkCode(phone,code,type):
            return ["phone":phone,"code":code,"type":type]
        case let .getFootPrintList(page,length):
            return ["page":page,"length":length]
        case let .deleteBrandCollect(cid,page,length):
            return ["cid":cid,"page":page,"length":length]
        case let .deleteGoodsCollect(cid,page,length):
            return ["cid":cid,"page":page,"length":length]
        case let .deleteShopAddress(addid):
            return ["addid":addid]
        case let .changeStroeMessage(glshop):
            return ["glShop":glshop]
        case let .buildNewPhone(phone,type,code):
            return ["phone":phone,"type":type,"code":code]
        case let .getBrandMoreList(page,length):
            return ["page":page,"length":length]
        case let .getOrderList(page,length,orderStatus,isevaluate):
            return ["page":page,"length":length,"orderstatus":orderStatus,"isevaluate":isevaluate]
        case let .getOrderDetails(orderid,iscanevaluate):
            return ["orderid":orderid,"iscanevaluate":iscanevaluate]
        case let .getOrderGroup(orderid,pdid):
            return ["orderid":orderid,"pdid":pdid]
        case let .confirmOrder(orderid):
            return ["orderid":orderid]
        case let .submitEvaluate(orderevaluates):
            return ["orderEvaluates":orderevaluates]
        case let .deleteOrder(orderid):
            return ["orderid":orderid]
        case let .cancelOrder(payid):
            return ["payid":payid]
        case let .getOrderLogistics(orderid):
            return ["orderid":orderid]
        case let .submitComplain(ooc_str):
            return ["ooc_str":ooc_str]
        case let .deleteFootPrint(fid):
            return ["fid":fid]
        case let .submitFeedBack(jsonStr):
            return ["jsonOsFeedback":jsonStr]
        case let .changeOrderStatus_Cancel(orderid,iscanevaluate,payid):
            return ["orderid":orderid,"iscanevaluate":iscanevaluate,"payid":payid]
        case let .changeOrderStatus_Confirm(orderid,iscanevaluate):
            return ["orderid":orderid,"iscanevaluate":iscanevaluate]
        case let .getMessageList(type,begin,length):
            return ["type":type,"begin":begin,"length":length]
        case let .getCouponsList(vstate):
            return ["vstate":vstate]
        case let .getComplaintsDetaile(id):
            return ["complainid":id]
        case let .getFeedBackDetaile(id):
            return ["feedbackid":id]
        case let .messageRed(mid):
            return ["mid":mid]
        case let .getOrderKD(orderid):
            return ["orderid":orderid]
        case let .getTKDetaile(detailid):
            return ["detailid":detailid]
        case let .login(username, password):
            return ["username": username, "password": password.getMd5Password()]
        case let .glproductskus(pdid):
            return ["pdid":pdid]
        default:
            return nil
        }
    }
}
